﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using System.Data;

namespace BLL
{
    public class MediaBLL
    {
        MediaDAL md = new MediaDAL();
        /// <summary>
        /// 获取素材dataset
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public DataSet getMedias(string type)
        {
            switch (type)
            {
                case "全部":
                    type = "";
                    break;
                case "图文素材":
                    type = "news";
                    break;
                case "图片素材":
                    type = "image";
                    break;
                case "视频素材":
                    type = "video";
                    break;
                default:
                    type = "voice";
                    break;
            }
            DataSet ds = md.getMedias(type);
            return ds;
        }
        /// <summary>
        /// 批量插入素材
        /// </summary>
        /// <param name="type"></param>
        /// <param name="Media_id"></param>
        /// <param name="title"></param>
        /// <param name="update_time"></param>
        public int updateMedia(DataTable dt, string tableName)
        {
            return md.updates(dt,tableName);
        }
        /// <summary>
        /// 清空表数据
        /// </summary>
        /// <param name="table"></param>
        public void truncateMedia(string table)
        {
            md.trunc(table);
        }
        /// <summary>
        /// 删除素材
        /// </summary>
        /// <param name="media_id"></param>
        public void delMedia(string media_id)
        {
            md.del(media_id);
        }
        //新增群发消息记录
        public bool addMassMsg(string weixinh, string mphelper, string createtime, string msgType, string events, int msgID, string status, int totalCount, int filterCount, int sentCount, int errorCount)
        {
            int i = md.addMass(weixinh,mphelper,createtime,msgType,events,msgID,status,totalCount,filterCount,sentCount,errorCount);
            if (i == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        //获取群发消息记录
        public DataSet getMassMsg()
        {
            DataSet ds = md.getMassMsg(1);
            return ds;
        }
    }
}
